<?php

include_once '_portal.php';

output(['success' => false, 'index' => -1, 'sql' => '']);
die();

$moment = $post->moment;
$timestamp = $post->timestamp;
$currentSectorCount = $post->currentSectorCount;
$autoAdvice = $post->autoAdvice;
$manualAdvice = $post->manualAdvice;
$manualDifference = $post->manualDifference;
$adviceDifference = $post->adviceDifference;
$rateZUUU = $post->rateZUUU;
$rateZUTF = $post->rateZUTF;
$updated = $post->updated;
$flowData = json_stringify($post->flowData);
$currentSector = json_stringify($post->currentSector);
$ip = get_client_ip();
$seat = get_client_seat($ip);

$sql = "INSERT INTO `2kt_note_flow`(`moment`, `timestamp`, `currentSectorCount`, `autoAdvice`, `manualAdvice`, `manualDifference`, `adviceDifference`, `rateZUUU`, `rateZUTF`, `flowData`, `currentSector`, `updated`, `ip`, `seat`) VALUES ('{$moment}',{$timestamp},{$currentSectorCount},{$autoAdvice},{$manualAdvice},{$manualDifference},{$adviceDifference},{$rateZUUU},{$rateZUTF},'{$flowData}','{$currentSector}','{$updated}','{$ip}','{$seat}')";

$result = exec_sql($sql);
$sql2 = "SELECT LAST_INSERT_ID() as lastID";
$result2 = null;
if ($result) {
  $result2 = exec_sql($sql2)[0]['lastID'];
}

output(['success' => $result, 'index' => $result2, '$sql' => $sql]);

/*
{
"moment": "2023-11-13 16:00:00",
"timestamp": 1699862400758,
"flowData": [],
"currentSectorCount": 2,
"currentSector": [],
"autoAdvice": 8,
"manualAdvice": 2,
"manualDifference": 0,
"adviceDifference": 6,
"rateZUUU": 98,
"rateZUTF": 98,
"updated": "2023-11-13 16:01:33"
}
 */